# 导包
import requests
from parameterized import parameterized

import utils
import unittest
from api.reg_API import REG_API


# 创建类

class TestLOGIN02(unittest.TestCase):
    #      前置处理
    def setUp(self) -> None:
        # 实例化封装类
        self.LOGINAPI = REG_API()
        # 实例化session
        self.session = requests.session()

    #        后置处理
    def tearDown(self) -> None:
        # 关闭session
        self.session.close()

    #          登录成功
    # 指定参数化的扩展数据方法
    @parameterized.expand(utils.read_json_file())
    # 直接使用参数化扩展数据名
    def test01_success_login(self, keywords, password, status_code, status, description):
        response = self.LOGINAPI.post_login(self.session, {"keywords": keywords, "password": password})
        print(response.json())
        # self.assertEqual(200, response.status_code)
        # self.assertEqual(200, response.json().get("status"))
        # self.assertIn("登录成功", response.text)
        utils.common_assert(self, response, status_code, status, description)

